package eu.connect.jmswrapper.callerproxies;

import java.io.Serializable;

import org.connect.enablers.discovery.repository.CNSInstance;
import org.connect.enablers.discovery.repository.NSRepositoryInterface;
import org.connect.storage.desc.ns.affordance.CNSAffordanceDesc;
import org.connect.storage.desc.ns.behavior.CNSBehaviorDesc;
import org.connect.storage.desc.ns.behavior.EnhancedLTS;
import org.connect.storage.desc.ns.inter.CNSInterfaceDesc;
import org.connect.storage.desc.ns.nfproperties.CNSNFPropertiesDesc;

import eu.connect.jmswrapper.*;

public class NSRepositoryInterfaceJMSCallerProxy extends ConnectJMSCallerProxy
		implements NSRepositoryInterface {

	@Override
	public CNSAffordanceDesc getNSAffordance(String arg0) {
		// TODO Auto-generated method stub
		ConnectJMSInvokeMessage jmsMsg = new ConnectJMSInvokeMessage();
		jmsMsg.setMethodName("getNSAffordance");
		jmsMsg.setParameterTypes(new Class[]{String.class});
		jmsMsg.setParameters(new Serializable[]{arg0});
		
		try {
			ConnectJMSSender sender = new ConnectJMSSender(jmsMsg,"NSRepositoryInterface");
			ConnectJMSReturnMessage returnMsg = sender.invoke();
			return (CNSAffordanceDesc)returnMsg.getReturnObj();
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public CNSBehaviorDesc getNSBehaviour(String arg0) {
		// TODO Auto-generated method stub
		ConnectJMSInvokeMessage jmsMsg = new ConnectJMSInvokeMessage();
		jmsMsg.setMethodName("getNSBehaviour");
		jmsMsg.setParameterTypes(new Class[]{String.class});
		jmsMsg.setParameters(new Serializable[]{arg0});
		
		try {
			ConnectJMSSender sender = new ConnectJMSSender(jmsMsg,"NSRepositoryInterface");
			ConnectJMSReturnMessage returnMsg = sender.invoke();
			return (CNSBehaviorDesc)returnMsg.getReturnObj();
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public CNSInstance getNSInstance(String arg0) {
		// TODO Auto-generated method stub
		ConnectJMSInvokeMessage jmsMsg = new ConnectJMSInvokeMessage();
		jmsMsg.setMethodName("getNSInstance");
		jmsMsg.setParameterTypes(new Class[]{String.class});
		jmsMsg.setParameters(new Serializable[]{arg0});
		
		try {
			ConnectJMSSender sender = new ConnectJMSSender(jmsMsg,"NSRepositoryInterface");
			ConnectJMSReturnMessage returnMsg = sender.invoke();
			return (CNSInstance)returnMsg.getReturnObj();
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public CNSInterfaceDesc getNSInterface(String arg0) {
		// TODO Auto-generated method stub
		ConnectJMSInvokeMessage jmsMsg = new ConnectJMSInvokeMessage();
		jmsMsg.setMethodName("getNSInterface");
		jmsMsg.setParameterTypes(new Class[]{String.class});
		jmsMsg.setParameters(new Serializable[]{arg0});
		
		try {
			ConnectJMSSender sender = new ConnectJMSSender(jmsMsg,"NSRepositoryInterface");
			ConnectJMSReturnMessage returnMsg = sender.invoke();
			return (CNSInterfaceDesc)returnMsg.getReturnObj();
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public CNSNFPropertiesDesc getNSNFProperties(String arg0) {
		// TODO Auto-generated method stub
		ConnectJMSInvokeMessage jmsMsg = new ConnectJMSInvokeMessage();
		jmsMsg.setMethodName("getNSNFProperties");
		jmsMsg.setParameterTypes(new Class[]{String.class});
		jmsMsg.setParameters(new Serializable[]{arg0});
		
		try {
			ConnectJMSSender sender = new ConnectJMSSender(jmsMsg,"NSRepositoryInterface");
			ConnectJMSReturnMessage returnMsg = sender.invoke();
			return (CNSNFPropertiesDesc)returnMsg.getReturnObj();
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public void updateNetworkedSystemBehaviour(CNSInstance arg0) {
		// TODO Auto-generated method stub
		ConnectJMSInvokeMessage jmsMsg = new ConnectJMSInvokeMessage();
		jmsMsg.setMethodName("updateNetworkedSystemBehaviour");
		jmsMsg.setParameterTypes(new Class[]{CNSInstance.class});
		jmsMsg.setParameters(new Serializable[]{arg0});
		
		try {
			ConnectJMSSender sender = new ConnectJMSSender(jmsMsg,"NSRepositoryInterface");
			sender.invoke();
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return;
	}

	@Override
	public void updateNetworkedSystemBehaviour(String arg0, EnhancedLTS arg1) {
		// TODO Auto-generated method stub
		ConnectJMSInvokeMessage jmsMsg = new ConnectJMSInvokeMessage();
		jmsMsg.setMethodName("updateNetworkedSystemBehaviour");
		jmsMsg.setParameterTypes(new Class[]{String.class,EnhancedLTS.class});
		jmsMsg.setParameters(new Serializable[]{arg0,arg1});
		
		try {
			ConnectJMSSender sender = new ConnectJMSSender(jmsMsg,"NSRepositoryInterface");
			sender.invoke();
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return;
	}

}
